/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package app.entities.model.MockDAOImpl;

import app.entities.MOCK.MockPersistencia;
import java.util.ArrayList;
import app.entities.model.DAO.MatriculaAlunoDAO;
import app.entities.model.DTO.MatriculaAlunoDTO;

/**
 *
 * @author Murilo
 */
public class MockMatriculaAlunoDAOImpl implements MatriculaAlunoDAO {

    @Override
    public void salvar(MatriculaAlunoDTO dto) {
        MockPersistencia.getInstanciaListaMatriculaAlunos().add(dto);
    }

    @Override
    public void deletar(MatriculaAlunoDTO dto) {
        MockPersistencia.getInstanciaListaMatriculaAlunos().remove(dto);
    }

    @Override
    public void atualizar(MatriculaAlunoDTO dto) {
        for (MatriculaAlunoDTO ma : MockPersistencia.getInstanciaListaMatriculaAlunos()) {
            if (ma.getId() == dto.getId()) {
                ma.setAluno(dto.getAluno());
                ma.setCodigoMatricula(dto.getCodigoMatricula());
                ma.setDataMatricula(dto.getDataMatricula());
                ma.setEstaAtiva(dto.isEstaAtiva());
            }
        }
    }

    @Override
    public ArrayList listar() {
        return MockPersistencia.getInstanciaListaMatriculaAlunos();
    }

    @Override
    public MatriculaAlunoDTO buscarMatriculaAluno(String Codigomatricula) {
        for (MatriculaAlunoDTO matricula : MockPersistencia.getInstanciaListaMatriculaAlunos()) {
            if (matricula.getCodigoMatricula().equals(Codigomatricula)) {
                return matricula;
            }
        }
        return null;
    }
}
